package com.mysql.study.service;

import com.mysql.study.Dao.GoodsDao;
import com.mysql.study.entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Random;

@Service
public class GoodsService {
    @Autowired
    private GoodsDao goodsDao;

    //根据主键查询数据
    @Transactional
    public Goods FindKeyIdGoods(int id){
        return this.goodsDao.selectByPrimaryKey(id);
    }

    /**
     * 查询所有数据
     * @return
     */
    @Transactional
    public List<Goods> GoodsAll(){
        return this.goodsDao.selectAllGoods();
    }

    /**
     * 根据主键删除数据
     */
    @Transactional
    public void GoodsDelete(int id){
     this.goodsDao.deleteByPrimaryKey(id);
    }


}
